﻿#include <stdio.h>

//main42：字符串比对（较）算法
int main42(void)
{

	char arr1[] = "abc";//abc-->abcde-->abc
	char arr2[] = "abc";//abcd-->abced-->abc
	int len1 = sizeof(arr1) / sizeof(arr1[0]);//4
	int len2 = sizeof(arr2) / sizeof(arr1[0]);//5
	int flag = 1;

	if (len1 != len2)
	{
		printf("1.字符串arr1-->%s和字符串arr2-->%s，不相同！\n", arr1, arr2);
	}
	else
	{
		for (int i = 0; i < len1 - 1; i++)
		{
			if (arr1[i] != arr2[i])
			{
				printf("2.字符串arr1-->%s和字符串arr2-->%s，不相同！\n", arr1, arr2);
				flag = -1;
				break;
			}
		}
	}
	if (flag > 0)
	{
		printf("3.字符串arr1-->%s和字符串arr2-->%s，相同！\n", arr1, arr2);//3.字符串arr1-->abc和字符串arr2-->abc，相同！
	}

	return 0;
}